package cn.achao.csr.file.controller;

import cn.achao.csr.base.resp.R;
import cn.achao.csr.file.core.model.resp.MinIoFileResp;
import cn.achao.csr.file.service.UploadService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: achao
 **/

@RestController
@RequestMapping("/file")
@RequiredArgsConstructor
public class FileController {

    private final UploadService uploadService;

    @PostMapping("upload")
    public R<?> upload(@RequestParam("file") MultipartFile file) {
        MinIoFileResp upload = uploadService.upload(file);
        return R.ok(upload);
    }

}
